import axios from 'axios';
import config from '@/../src/config/index';

const defaultWmsUrl = process.env.NODE_ENV === 'development'
    ? config.wmsUrl.dev
    : process.env.VUE_APP_MODE === 'testEnvironment'
        ? config.wmsUrl.dev
        :  process.env.VUE_APP_MODE === 'temporary'
            ? config.wmsUrl.temporary
            :  process.env.VUE_APP_MODE === 'prod'
                ? config.wmsUrl.pro
                : config.wmsUrl.dev;

  // 入库计划
export function getWarehousingList(data, wmsUrl= defaultWmsUrl) {
    return axios({
        // url: wmsUrl + '/api/wms_in_plan/page',
        url: wmsUrl + '/api/ccis_in_stock_apply/selectPage',
        method: 'post',
        data,
        parameter: {
          type: 'WMS'
      }
    });
}
export function getWarehousingInfo(data, wmsUrl= defaultWmsUrl) {
  return axios({
      url: wmsUrl + '/api/wms_in_plan/selectChargeData',
      method: 'post',
      data,
      parameter: {
        type: 'WMS'
    }
  });
}
export function getWarehousingDtail(data, wmsUrl= defaultWmsUrl) {
  return axios({
      url: wmsUrl + '/api/wms_in_plan/selectByInPlanOrderNum',
      method: 'post',
      data,
      parameter: {
        type: 'WMS'
    }
  });
}
export function getWarehousingDtails(data, wmsUrl= defaultWmsUrl) {
  return axios({
      url: wmsUrl + '/api/wms_in_plan/selectByInPlanOrderNumForLenglian',
      method: 'post',
      data,
      parameter: {
        type: 'WMS'
    }
  });
}
// 出库计划
export function getExWarehouseList(data, wmsUrl= defaultWmsUrl) {
  return axios({
      // url: 'http://172.16.0.153:8088' + '/api/wms_out_plan/page',
      url: wmsUrl + '/api/ccis_out_stock_apply/page',
      // url: 'http://192.168.89.240:8088' + '/api/ccis_out_stock_apply/page',
      // url: wmsUrl + '/api/wms_out_plan/page',
      method: 'post',
      data,
      parameter: {
        type: 'WMS'
    }
  });
}
export function getExWarehouseInfo(data, wmsUrl= defaultWmsUrl) {
  return axios({
      url: wmsUrl + '/api/wms_out_plan/selectByOutPlanOrderNum',
      method: 'post',
      data,
      parameter: {
        type: 'WMS'
    }
  });
}

// 货转单据
// export function getGoodsTransferList(data, wmsUrl= defaultWmsUrl) {
//   return axios({
//       url: wmsUrl + '/api/wms_stock_prop_change_order/page',
//       method: 'post',
//       data
//   });
// }

export function getGoodsTransferInfo(data, wmsUrl= defaultWmsUrl) {
  return axios({
      url: wmsUrl + '/api/wms_out_plan/selectByOutPlanOrderNum',
      method: 'post',
      data,
      parameter: {
        type: 'WMS'
    }
  });
}
// 分色单据
export function getColorSeparationList(data, wmsUrl= defaultWmsUrl) {
  return axios({
      // url: wmsUrl + '/api/ccis_sep_stock_apply/page',
      url: wmsUrl + '/api/ccis_separation_apply/lenglianSelectPage',
      method: 'post',
      data
  });
}
export function getColorSeparationInfo(data, wmsUrl= defaultWmsUrl) {
  return axios({
      url: wmsUrl + '/api/wms_separation_order_hd/querySeparationOrderDetail',
      method: 'post',
      data,
      parameter: {
        type: 'WMS'
    }
  });
}
export function getStockPropChangeDetail(data, wmsUrl= defaultWmsUrl) {
  return axios({
      url: wmsUrl + '/api/wms_stock_prop_change_order/getStockPropChangeDetail',
      method: 'post',
      data,
      parameter: {
        type: 'WMS'
    }
  });
}
export function getCompleteOrderInfo(data) {
  return axios({
      url:'/api/platform_warehouse/getNotCompleteOrderNumWeiList',
      method: 'post',
      data
  });
}
export function getCompleteOrderInfoH(data) {
  return axios({
      url:'/api/platform_warehouse/getNotCompleteOrderNumWei',
      method: 'post',
      data
  });
}
// 入库计划商品弹窗列表新增商品
export function addIntoMaterialData (query, wmsUrl= defaultWmsUrl) {
  return axios.request({
    url:  wmsUrl +'/api/wms_material/addIntoMaterialData',
    method: 'post',
    data: query,
    parameter: {
      type: 'WMS'
  }
  })
}
// 新增出库计划
export function createOutPlanAndOutPlanDetail(query, wmsUrl= defaultWmsUrl) {
  return axios.request({
    url: wmsUrl +'/api/wms_out_plan/createOutPlanAndOutPlanDetail',
    // url: 'http://172.16.1.3:8088' + '/api/wms_out_plan/createOutPlanAndOutPlanDetail',
    method: 'post',
    data: query,
    parameter: {
      type: 'WMS'
  }
  })
}
export function page(data, wmsUrl= defaultWmsUrl) {
  return axios({
      url: wmsUrl + '/api/wms_out_plan/getEditDataByWmsStock',
      // url:  'http://192.168.89.240:8088' + '/api/wms_out_plan/getEditDataByWmsStock',
      method: 'post',
      data,
      parameter: {
        type: 'WMS'
      }
  });
}
export function TCpage(data, wmsUrl= defaultWmsUrl) {
  return axios({
      url: wmsUrl + '/api/wms_stock_separation_plan_child_detail/page',
      method: 'post',
      data,
      parameter: {
        type: 'WMS'
      }
  });
}
// 入库新建
export function WarehousingCreted(data, wmsUrl= defaultWmsUrl) {
  return axios({
      url:  wmsUrl + '/api/ccis_in_stock_apply/createApplyAndApplyDetail',
      method: 'post',
      data,
      parameter: {
        type: 'WMS'
      }
  });
}

// 入库新建 获取箱信息
export function getBoxInfoWarehousing(data, wmsUrl= defaultWmsUrl) {
  return axios({
      url:  wmsUrl + '/api/ccis_in_stock_apply/selectPage',
      method: 'post',
      data,
      parameter: {
        type: 'WMS'
      }
  });
}
// 出库新建
export function createOutStockApply(data, wmsUrl= defaultW) {
  return axios({
    url:  wmsUrl + '/api/ccis_out_stock_apply/createOutStockApply',
    // url: 'http://172.16.1.3:8088' + '/api/ccis_out_stock_apply/createOutStockApply',
    method: 'post',
    data,
    parameter: {
      type: 'WMS'
    }
  });
}

// 入库附件列表/api/wms_file/page
export function getInfoWDtailRK(data, wmsUrl= defaultWmsUrl) {
  return axios({
      url:  wmsUrl + '/api/wms_file/page',
      method: 'post',
      data,
      parameter: {
        type: 'WMS'
      }
  });
}
// post
// {
//   "pageNum": 1,
//   "pages": 1,
//   "pageSize": 50,
//   "pageOptionsList": [
//     50,
//     100,
//     200
//   ],
//   "total": 1,
//   "sortList": [],
//   "filterList": [],
//   "selectCustomerCode": "",
//   "selectInPlanOrderNum": "P2022081600006",
//   "searchOrderType": "into"
// }
// 出库附件列表/api/wms_file/page
export function getInfoWDtailCK(data, wmsUrl= defaultWmsUrl) {
  return axios({
      url:  wmsUrl + '/api/wms_file/page',
      method: 'post',
      data,
      parameter: {
        type: 'WMS'
      }
  });
}
// post
// {
//   "pageNum": 1,
//   "pages": 1,
// "pageSize": 50,
//   "pageOptionsList": [
//     50,
//     100,
//     200
//   ],
//   "total": 0,
//   "sortList": [],
//   "filterList": [],
//   "selectCustomerCode": "",
//   "selectOutPlanOrderNum": "OP2022081600003"
// }

// 获取品类
export function getCategoryInfo(wmsUrl= defaultWmsUrl) {
  return axios({
      url:  wmsUrl + '/api/dictionary/MAT_TYPE/list',
      method: 'get',
      parameter: {
        type: 'WMS'
      }
  });
}
// 获取业务类型
export function getBusinessInfo( wmsUrl= defaultWmsUrl) {
  return axios({
      url:  wmsUrl + '/api/dictionary/INTO_BUS_TYPE/list',
      method: 'get',
      parameter: {
        type: 'WMS'
      }
  });
}
// 获取品名
export function getBusinessInfos(data, wmsUrl= defaultWmsUrl) {
  return axios({
      url:  wmsUrl + '/api/wms_in_plan/fuzzyQuery',
      // url:  wmsUrl + '/api/wms_material/selectAllMaterial',
      method: 'post',
      data,
      parameter: {
        type: 'WMS'
      }
  });
}
// 分色获取品名
export function getBusinessInfosFS(data, wmsUrl= defaultWmsUrl) {
  return axios({
      // url:  wmsUrl + '/api/wms_in_plan/fuzzyQuery',
      url:  wmsUrl + '/api/wms_material/selectAllMaterial',
      method: 'post',
      data,
      parameter: {
        type: 'WMS'
      }
  });
}
// 入库编辑
// export function updataBoxInfoWarehousing(data, wmsUrl= defaultWmsUrl) {
//   return axios({
//       url:  wmsUrl + '/api/ccis_in_stock_apply/updateApplyAndApplyDetail',
//       method: 'post',
//       data,
//       parameter: {
//         type: 'WMS'
//       }
//   });
// }
// 包装规格

export function packingSpecification(wmsUrl= defaultWmsUrl) {
  return axios({
      url:  wmsUrl + '/api/dictionary/PACKAGE_TYPE/list',
      method: 'get',
      parameter: {
        type: 'WMS'
      }
  });
}
// 货物规格
export function getCargoSpecification(body, wmsUrl= defaultWmsUrl) {
  return axios({
      url:  wmsUrl + '/api/wms_pack/selectPackInfo',
      method: 'post',
      parameter: {
        type: 'WMS'
      },
      data: body
  });
}

// 删除入库计划
export function deleteApplyAndApplyDetail(body, wmsUrl= defaultWmsUrl) {
  return axios({
      url:  wmsUrl + '/api/ccis_in_stock_apply/deleteApplyAndApplyDetail',
      method: 'post',
      parameter: {
        type: 'WMS'
      },
      data: body
  });
}

// 提交入库计划
export function submitApply(body, wmsUrl= defaultWmsUrl) {
  return axios({
      url:  wmsUrl + '/api/ccis_in_stock_apply/submitApply',
      method: 'post',
      parameter: {
        type: 'WMS'
      },
      data: body
  });
}

// 根据箱信息查看详情
export function selectApplyDetail(body, wmsUrl= defaultWmsUrl) {
  return axios({
      url:  wmsUrl + '/api/ccis_in_stock_apply/selectApplyDetail',
      method: 'post',
      parameter: {
        type: 'WMS'
      },
      data: body
  });
}

// 入库编辑
export function updateApplyAndApplyDetail(body, wmsUrl= defaultWmsUrl) {
  return axios({
      url:  wmsUrl + '/api/ccis_in_stock_apply/updateApplyAndApplyDetail',
      method: 'post',
      parameter: {
        type: 'WMS'
      },
      data: body
  });
}

// 出库库存查询
export function getStockListByOwnerCode(body, wmsUrl= defaultWmsUrl) {
  return axios({
      // url:  'http://192.168.89.240:8088' + '/api/wms_stock/getStockListByCCisCustomerCode',
      url:  wmsUrl + '/api/wms_stock/getStockListByOwnerCode',
      // url:  wmsUrl + '/api/ccis_out_stock_apply/getStockListByOwnerCode',
      method: 'post',
      parameter: {
        type: 'WMS'
      },
      data: body
  });
}
// 出库库存查询
export function getStockListByOwnerCodeForLenglian(body, wmsUrl= defaultWmsUrl) {
  return axios({
      url:  wmsUrl + '/api/wms_stock/getStockListByOwnerCodeForLenglian',
      method: 'post',
      parameter: {
        type: 'WMS'
      },
      data: body
  });
}

// 已选物品
export function selectByOutPlanOrderNum(body, wmsUrl= defaultWmsUrl) {
  return axios({
      // url:  'http://192.168.89.240:8088' + '/api/wms_out_plan/selectByOutPlanOrderNum',
      url:  wmsUrl + '/api/wms_out_plan/selectByOutPlanOrderNum',
      method: 'post',
      parameter: {
        type: 'WMS'
      },
      data: body
  });
}

// 验证箱号
export function testContainerNumber(body, wmsUrl= defaultWmsUrl) {
  return axios({
      // url:  'http://192.168.89.240:8088' + '/testContainerNumber',
      url:  wmsUrl + '/testContainerNumber?containerNumber=' + body,
      method: 'get',
      parameter: {
        type: 'WMS'
      }
  });
}

//获取库区
export function getAllStgData(wmsUrl= defaultWmsUrl) {
  return axios({
      // url:  'http://192.168.89.240:8088' + '/api/wms_stg_typ/getAllStgData',
      url:  wmsUrl + '/api/wms_stg_typ/getAllStgData',
      method: 'POST',
      parameter: {
        type: 'WMS'
      }
  });
}

// 删除出库
export function delCcisOutStockApply(body,wmsUrl= defaultWmsUrl) {
  return axios({
      // url:  'http://192.168.89.240:8088' + '/api/ccis_out_stock_apply/delCcisOutStockApply',
      url:  wmsUrl + '/api/ccis_out_stock_apply/delCcisOutStockApply',
      method: 'POST',
      parameter: {
        type: 'WMS'
      },
      data: body
  });
}


export function getAllCompleteOrderNumWei(body,wmsUrl= defaultWmsUrl) {
  return axios({
      // url:  'http://172.16.0.153:8088' + '/api/receive_ccis_order/getAllCompleteOrderNumWei',
      url:  wmsUrl + '/api/receive_ccis_order/getAllCompleteOrderNumWei',
      method: 'POST',
      parameter: {
        type: 'WMS'
      },
      data: body
  });
}

// 出库提交
export function submitApplyC(body,wmsUrl= defaultWmsUrl) {
  return axios({
      // url:  'http://192.168.89.240:8088' + '/api/ccis_out_stock_apply/submitApply',
      url:  wmsUrl + '/api/ccis_out_stock_apply/submitApply',
      method: 'POST',
      parameter: {
        type: 'WMS'
      },
      data: body
  });
}

// 出库查看
export function selectCcisOutStockApplyAndGoodsById(body,wmsUrl= defaultWmsUrl) {
  return axios({
      // url:  'http://192.168.89.240:8088' + '/api/ccis_out_stock_apply/selectCcisOutStockApplyAndGoodsById/' + body,
      url:  wmsUrl + '/api/ccis_out_stock_apply/selectCcisOutStockApplyAndGoodsById/' + body,
      method: 'POST',
      parameter: {
        type: 'WMS'
      },
      data: body
  });
}

export function selectCarNo(body,wmsUrl= defaultWmsUrl) {
  return axios({
    url:  wmsUrl + '/api/ccis_out_stock_apply/selectCarNo/' + body,
    method: 'POST',
    parameter: {
      type: 'WMS'
    },
    data: body
  });
}

// 货转列表
export function getGoodsTransferList(body,wmsUrl= defaultWmsUrl) {
  return axios({
      // url:  'http://192.168.89.240:8088' + '/api/ccis_prop_stock_apply/page',
      url:  wmsUrl + '/api/ccis_prop_stock_apply/page',
      method: 'POST',
      parameter: {
        type: 'WMS'
      },
      data: body
  });
}

// 出库有计划单号
export function getEditDataByWmsStock(body,wmsUrl= defaultWmsUrl) {
  return axios({
      // url:  'http://192.168.89.240:8088' + '/api/wms_out_plan/getEditDataByWmsStock',
      url:  wmsUrl + '/api/wms_out_plan/selectByOutPlanOrderNum',
      method: 'POST',
      parameter: {
        type: 'WMS'
      },
      data: body
  });
}

// 入库EDOC
export function REdoc(body,wmsUrl= defaultWmsUrl) {
  return axios({
      url:  wmsUrl + '/api/wms_file/selectFileByPlanNumAndType',
      // url:  'http://172.16.0.153:8088' + '/api/wms_file/page',
      method: 'POST',
      parameter: {
        type: 'WMS'
      },
      data: body
  });
}

// 出库编辑
export function updateOutStockApply(body,wmsUrl= defaultWmsUrl) {
  return axios({
      url:  wmsUrl + '/api/ccis_out_stock_apply/updateOutStockApply',
      // url:  'http://192.168.89.240:8088' + '/api/ccis_out_stock_apply/updateOutStockApply',
      method: 'POST',
      parameter: {
        type: 'WMS'
      },
      data: body
  });
}

// EDOC下载
export function customerDownload(body,wmsUrl= defaultWmsUrl) {
  return axios({
      url:  wmsUrl + '/api/wms_file/customerDownload',
      method: 'POST',
      parameter: {
        type: 'WMS'
      },
      data: body,
      responseType: 'blob'
  });
}

// EDOC 查询
export function selectEDocByBusinessItem(body, wmsUrl= defaultWmsUrl) {
  return axios({
      url:  wmsUrl + '/api/wms_stock/selectEDocByBusinessItem',
      method: 'POST',
      parameter: {
          type: 'WMS'
      },
      data: body
  });
}

// CODE转换
export function selectCustomerInfoByDto(body,wmsUrl= defaultWmsUrl) {
  return axios({
      url:  wmsUrl + '/api/crm_customer_info/selectCustomerInfoByDto',
      method: 'POST',
      parameter: {
        type: 'WMS'
      },
      data: body,
  });
}

//
export function selectPdf(body,wmsUrl= defaultWmsUrl) {
  return axios({
      url:  wmsUrl + '/iwms/services/rest/rpcService/containerWms/selectPdf',
      method: 'POST',
      parameter: {
        type: 'WMS'
      },
      data: body,
  });
}

// 获取所有结算客户
export function getAllOwner(wmsUrl= defaultWmsUrl) {
  return axios({
      url:  wmsUrl + '/api/wms_owner/getAllOwner',
      method: 'POST',
      parameter: {
        type: 'WMS'
      }
  });
}

// 货主
export function getOwnerCodeListByStock(body,wmsUrl= defaultWmsUrl) {
  return axios({
      url:  wmsUrl + '/api/wms_stock/getOwnerCodeListByStock',
      method: 'POST',
      parameter: {
        type: 'WMS'
      },
      data: body
  });
}

// /api/platform_warehouse/getAllCompleteOrderNumWei

export function getAllCompleteOrderNumWeiT(body) {
  return axios({
      // url:  wmsUrl + '/api/platform_warehouse/getAllCompleteOrderNumWei',
      url:  '/api/platform_warehouse/getAllCompleteOrderNumWei',
      method: 'post',
      data: body
  });
}


export function getGoodsTransfer(body,wmsUrl= defaultWmsUrl) {
  return axios({
      // url:  wmsUrl + '/api/platform_warehouse/getAllCompleteOrderNumWei',
      url: wmsUrl +  '/api/wms_batch_attribute/getGoodsTransfer',
      method: 'POST',
      parameter: {
        type: 'WMS'
      },
      data: body
  });
}

export function addProp(body,wmsUrl= defaultWmsUrl) {
  return axios({
      // url:  wmsUrl + '/api/ccis_prop_change_order/addProp',
      url: wmsUrl +  '/api/ccis_prop_change_order/addProp',
      method: 'POST',
      parameter: {
        type: 'WMS'
      },
      data: body
  });
}

// packageType
// 货转列表
export function getPage(body,wmsUrl= defaultWmsUrl) {
  return axios({
      url: wmsUrl +  '/api/ccis_prop_change_order/page',
      method: 'POST',
      parameter: {
        type: 'WMS'
      },
      data: body
  });
}
// 分色信息
export function getSepPlanInfo(data,wmsUrl= defaultWmsUrl) {
  return axios({
    url:  wmsUrl + '/api/wms_stock/getStockListByOwnerCode',
    method: 'POST',
    parameter: {
      type: 'WMS'
    },
    data
  })
}

// 分色新增
export function createdSepPlanInfo(data,wmsUrl= defaultWmsUrl) {
  return axios({
    // url:  wmsUrl + '/api/ccis_separation_apply/createApplyAndApplyDetail',
    url:wmsUrl + '/api/ccis_separation_apply/createApplyAndApplyDetail',
    method: 'POST',
    parameter: {
      type: 'WMS'
    },
    data
  })
}


// 分色客户
export function getSepPlanKehu(data,wmsUrl= defaultWmsUrl) {
  return axios({
    url:  wmsUrl + '/api/wms_customer/selectByCustomerType',
    method: 'POST',
    parameter: {
      type: 'WMS'
    },
    data
  })
}

// 货转删除
export function deleteProp(body,wmsUrl= defaultWmsUrl) {
  return axios({
    url:  wmsUrl + '/api/ccis_prop_change_order/deleteProp?orderNum=' + body,
    method: 'GET',
    parameter: {
      type: 'WMS'
    },
  })
}

export function submitProp(body,wmsUrl= defaultWmsUrl) {
  return axios({
    url:  wmsUrl + '/api/ccis_prop_change_order/submitProp?orderNum=' + body,
    method: 'GET',
    parameter: {
      type: 'WMS'
    }
  })
}


export function getSeparateOrderDetail(body,wmsUrl= defaultWmsUrl) {
  return axios({
    url:  wmsUrl + '/api/wms_separation_order_hd/querySeparationOrderPrintInfo',
    method: 'POST',
    parameter: {
      type: 'WMS'
    },
    data: body
  })
}


export function editProp(body,wmsUrl= defaultWmsUrl) {
  return axios({
    url:  wmsUrl + '/api/ccis_prop_change_order/editProp',
    method: 'POST',
    parameter: {
      type: 'WMS'
    },
    data: body
  })
}

export function selectPackInfo(body,wmsUrl= defaultWmsUrl) {
  return axios({
    url:  wmsUrl + '/api/wms_pack/selectPackInfo',
    method: 'POST',
    parameter: {
      type: 'WMS'
    },
    data:body
  })
}

// 分色客户
export function getSepPlanInDtail(data,wmsUrl= defaultWmsUrl) {
  return axios({
    url: wmsUrl + '/api/ccis_separation_apply/lenglianSelectParentByOrderNum',
    method: 'POST',
    parameter: {
      type: 'WMS'
    },
    data
  })
}
//  目标分色
export function getSepPlanInDtailM(data,wmsUrl= defaultWmsUrl) {
  return axios({
    url:  wmsUrl + '/api/ccis_separation_apply/lenglianSelectChildByOrderNum',
    method: 'POST',
    parameter: {
      type: 'WMS'
    },
    data
  })
}

// 获取目标分色数据
export function getFuzzyQuery(data,wmsUrl= defaultWmsUrl) {
  return axios({
    url:  wmsUrl + '/api/wms_in_plan/fuzzyQuery',
    method: 'POST',
    parameter: {
      type: 'WMS'
    },
    data
  })
}

// 获取仓库列表
export function selectBoxNumPage(data,wmsUrl= defaultWmsUrl) {
  return axios({
    url:  wmsUrl + '/api/ccis_apply_summary/selectBoxNumPage',
    method: 'POST',
    parameter: {
      type: 'WMS'
    },
    data
  })
}

// EDOC下载
export function downloadFile(url) {
    return axios({
        url:  '/cargo/api/operedoc/downloadFile',
        method: 'GET',
        params: url,
        responseType: 'blob'
    });
}



// 上海货转计划列表
export function selectTransList(data,wmsUrl= defaultWmsUrl) {
  return axios({
      url:  wmsUrl + '/api/receive_ccis_order/selectTransList',
      method: 'POST',
      parameter: {
        type: 'WMS'
      },
      data
  });
}
